
{include file="Include/H_ui_head" /}

<article class="page-container">
    <div class="page-container">
        <form action="javascript:;" method="post" class="form form-horizontal" id="form-admin-add" enctype="multipart/form-data">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>会员手机号：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text " value="{$data.phone}" placeholder="" id="phone" name="phone">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>充值时间：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text " value="{$data.addtime}" placeholder="" id="addtime" name="addtime">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>充值方式：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="radio" name="money_type" value="安卓"><label>安卓</label>
                    <input type="radio" name="money_type" value="ios"><label>ios</label>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>到期时间：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text " value="{$data.endtime}" placeholder="" id="endtime" name="endtime">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>经营范围：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    {volist name="professions" id="pros"}
                    <dl class="permission-list">
                        <dt>
                            <label>
                                <input type="checkbox" value="" id="user-Character-1">
                                {$pros.typeName}</label>
                        </dt>
                        <dd>
                            <dl class="cl permission-list2">
                                {foreach $pros.profession as $profession}
                                <dt>
                                    <label class="">
                                        <input type="checkbox" value="{$profession.p_id}" class="" name="pid[]" id="user-Character-1-0">
                                        {$profession.pname}</label>
                                </dt>
                                {/foreach}
                            </dl>
                        </dd>
                    </dl>
                    {/volist}
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>类型：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="radio" name="m_type" value="1"><label>月会员</label>
                    <input type="radio" name="m_type" value="2"><label>季会员</label>
                    <input type="radio" name="m_type" value="3"><label>年会员</label>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>订单号：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text " value="{$data.m_identifier}" placeholder="" id="m_identifier" name="m_identifier">
                </div>
            </div>
            <div class="row cl" id="sub">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input type="hidden" name="m_id" value="{$data.m_id}">
                    <button class="btn btn-primary radius" onclick="return edit()"> 提交</button>
                </div>
            </div>
        </form>
    </div>
</article>
{include file="Include/H_ui_foot" /}
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript">
    //默认值选中
    window.onload=function(){
        var pid = '{$data["pid"]}';
        var pids = pid.split(",");
        $("[name='phone']").attr("disabled",true);
        $("[name='m_identifier']").attr("disabled",true);
        $("[value='{$data['money_type']}']").attr('checked',true);
        $("[value='{$data['m_type']}']").attr('checked',true);
        for(var i=0; i<pids.length; i++){
            $('[value="'+pids[i]+'"]').attr('checked',true);
        }
        var type = "{$data['type']}";
        //是否显示提交按钮
        if(type == 'see'){
            $("#sub").hide();
            $("input").attr("disabled",true);
        }
    }
    $(function(){
        $(".permission-list dt input:checkbox").click(function(){
            $(this).closest("dl").find("dd input:checkbox").prop("checked",$(this).prop("checked"));
        });
        $(".permission-list2 dd input:checkbox").click(function(){
            var l =$(this).parent().parent().find("input:checked").length;
            var l2=$(this).parents(".permission-list").find(".permission-list2 dd").find("input:checked").length;
            if($(this).prop("checked")){
                $(this).closest("dl").find("dt input:checkbox").prop("checked",true);
                $(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked",true);
            }
            else{
                if(l==0){
                    $(this).closest("dl").find("dt input:checkbox").prop("checked",false);
                }
                if(l2==0){
                    $(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked",false);
                }
            }
        });

    });

    function edit()
    {
        var params = $('form').serializeArray();
        var loading =layer.msg('正在提交数据，请稍后...',{time:5000});
        $.post('{:url("Member/edit")}',params,function(data){
            layer.close(loading);
            if(data.code=='1'){
                layer.msg(data.msg,{time:2000});
                setTimeout(function(){
                    layer_close(this.index);
                },1000);
            }else{
                layer.msg(data.msg,{time:2000});
            }
        });
    }

</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>
